package cn.tedu.review;

/**
 * @author ：Dsi
 * @date ：2021/11/22 9:33
 * Describe ：该类用于复习多线程实现编程方案二：实现Runnable
 */
public class TestRunnable01 {
    public static void main(String[] args) {
        Runnable r = new Runnable1();
        Thread t1=new Thread(r);
        Thread t2=new Thread(r);
        Thread t3=new Thread(r);
        Thread t4 = new Thread(r);
        t1.start();
        t2.start();
        t3.start();
        t4.start();


    }
}
class Runnable1 implements Runnable {
    @Override
    public void run() {
        int ticket=100;
        while (true){
            //System.out.println(new Thread().getName() + "=" + ticket--);//会出现错误
            System.out.println(Thread.currentThread().getName() + "=" + ticket--);
            if(ticket<=0)break;
        }
    }
}